package com.soft.javase.day13;

import java.util.concurrent.CountDownLatch;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/5/22
 */
public class CountDownLatchDemo {
    public static void main(String[] args) {
        CountDownLatch latch = new CountDownLatch(1);

        new Thread(() -> {
            System.out.println("A");
            try {
                latch.await();
                System.out.println("C");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "线程1").start();

        new Thread(() -> {
            System.out.println("B");
            latch.countDown();
        }, "线程2").start();
    }
}
